/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package jadeproject;

import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.util.ExtendedProperties;
import java.util.Properties;
import jade.wrapper.AgentContainer;
import jade.wrapper.AgentController;
import jade.wrapper.ControllerException;
import libPackage.CommonFunction;
import java.util.Random;
/**
 *
 * @author duonghau
 */
public class JadeProject {

    /**
     * @param args the command line arguments
     */
    
    public static void main(String[] args) {
        int number_of_plante=0;
        int number_of_herbivore=0;
        int number_of_carnivore=0;
        int number_of_homme=0;
        JadeProject jadeProject=new JadeProject();
        CommonFunction commonFunction=new CommonFunction();
        Random random=new Random();
        try{
            jade.core.Runtime runtime=jade.core.Runtime.instance();
            jade.util.leap.Properties properties= new ExtendedProperties();
            properties.setProperty(Profile.GUI, "true");
            ProfileImpl profileImpl=new ProfileImpl(properties);
            AgentContainer agentContainer=runtime.createMainContainer(profileImpl);
            Properties configProperties=commonFunction.getProperties();
            if(configProperties!=null){
                number_of_plante=Integer.parseInt(configProperties.getProperty("number_init_plante"));
                number_of_herbivore=Integer.parseInt(configProperties.getProperty("number_init_herbivore"));
                number_of_carnivore=Integer.parseInt(configProperties.getProperty("number_init_carnivore"));
                number_of_homme=Integer.parseInt(configProperties.getProperty("number_init_homme"));                
            }
            commonFunction.createNewAgent(agentContainer, "Environnement", "environnement.Environnement");
            for(int i=0;i<number_of_plante;i++){
                commonFunction.createNewAgent(agentContainer, "plante_"+i, "agents.Plante");
            }        
            for(int i=0;i<number_of_herbivore;i++){
                commonFunction.createNewAgent(agentContainer, "herbivore_"+i, "agents.Herbivore");
            }
            for(int i=0;i<number_of_carnivore;i++){
                commonFunction.createNewAgent(agentContainer, "carnivore_"+i, "agents.Carnivore");
            }
//            for(int i=0;i<number_of_homme;i++){
//                commonFunction.createNewAgent(agentContainer, "homme"+i, "agents.Homme");
//            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    
}
